Skip to content

Added interactive quantum circuit playground with tutorials#9

Open
CodeMaverick2 wants to merge 3 commits intoOpenQuantumDesign:mainfrom
CodeMaverick2:feat/quantum-circuit-playground
Open

Added interactive quantum circuit playground with tutorials#9
CodeMaverick2 wants to merge 3 commits intoOpenQuantumDesign:mainfrom
CodeMaverick2:feat/quantum-circuit-playground

Conversation

@CodeMaverick2
Copy link
Copy Markdown

@CodeMaverick2 CodeMaverick2 commented Feb 24, 2026

Summary

Interactive digital quantum circuit builder that lets users visually build circuits, simulate quantum states, and execute on hardware. Complements the analog program builder (#5) to complete the teaching demo for Issue #3.

What's New

3 new modules:

  • digital_simulator.py - quantum state simulation (kronecker product math, measurement sampling)
  • digital_compiler.py - compiles Circuit → laser intensity patterns + trap commands
  • gui/circuit_builder.py - interactive NiceGUI UI with circuit grid, gate palette, and results panel

Modified:

  • digital.py - fixed pydantic v2 compatibility (root_validatormodel_validator), relaxed qubit count to match 4-laser hardware
  • gui/programs.py - added preset circuits (Bell state, GHZ, superposition, X gate)
  • gui/main.py - wired "Quantum Playground" button to circuit builder

Features:

  • 4×6 clickable circuit grid (qubits × time steps) with I/X/Z/H/CNOT gates
  • Real-time quantum simulation with state vector display and probability bar charts
  • Measurement sampling (100/1000 shots) with histogram visualization
  • Hardware execution — lasers fire per gate, trap shakes during CNOT
  • 4 guided tutorials: Superposition, Bit Flip, Entanglement (Bell State), GHZ State
  • Export: "Show Circuit JSON" (OQD digital IR) and "Show Laser Program" (compiled hardware commands)
  • No new dependencies (uses NiceGUI's built-in ECharts)

Demo -

Screen.Recording.2026-02-24.110521.1.mp4

Test Plan

  • python src/oqd_teaching_demo/gui/main.py starts without errors (MOCK=True)
  • All 4 tutorials load correct presets and step text
  • Free Build: place/clear/reset gates, add/remove columns
  • Simulate shows correct state vectors and probabilities
  • Sample 100/1000 shots produces histogram
  • Run on Hardware fires mock lasers + trap shake for CNOT
  • Show Circuit JSON and Show Laser Program display correct output
  • No new dependencies added

Closes - #3

@CodeMaverick2
Copy link
Copy Markdown
Author

@benjimaclellan Would love your feedback on this and if any changes are required do let me know

@SecludedPerson700
Copy link
Copy Markdown

@CodeMaverick2

Why are yu copying from others PR, kindly give some chance to other participants thank you Maintainer please take note while reviewing

@CodeMaverick2
Copy link
Copy Markdown
Author

CodeMaverick2 commented Feb 24, 2026

@SecludedPerson700

I’m not sure what you mean. If you’re suggesting that I copied your PR, I’d encourage you to carefully review both submissions they are quite different, and mine directly addresses the requirements outlined in the issue.

I had discussed my implementation plan with the maintainer before starting work when no one had commented on the issue. I’ve also closed another issue in this repository, so I’m familiar with the expected standards.

Additionally, I’d recommend reviewing your own PR again it may help clarify how the issue requirements are intended to be solved.

If you have specific technical concerns, I’m happy to discuss them constructively. Let’s keep the conversation focused on the code and the actual requirements.

Making accusations without clear evidence isn’t productive, and difficulty in solving an issue isn’t a valid reason to blame others

@SecludedPerson700
Copy link
Copy Markdown

SecludedPerson700 commented Feb 24, 2026

@SecludedPerson700

I’m not sure what you mean. If you’re suggesting that I copied your PR, I’d encourage you to carefully review both submissions they are quite different, and mine directly addresses the requirements outlined in the issue.

I had discussed my implementation plan with the maintainer before starting work when no one had commented on the issue. I’ve also closed another issue in this repository, so I’m familiar with the expected standards.

Additionally, I’d recommend reviewing your own PR again it may help clarify how the issue requirements are intended to be solved.

If you have specific technical concerns, I’m happy to discuss them constructively. Let’s keep the conversation focused on the code and the actual requirements.

Making accusations without clear evidence isn’t productive, and difficulty in solving an issue isn’t a valid reason to blame others

maintainers kindly note while reviewing thank yu i will leave this to the maintainers

@SecludedPerson700
Copy link
Copy Markdown

@learningdungeon @AbdullahKazi500 @ dhanaa abhirjk hey guys I would also suggesst checking yur work and pr if you made any contributions for the issue thnks again .

@benjimaclellan
Copy link
Copy Markdown
Member

Hi @CodeMaverick2 - thanks for another PR! It looks great, and complements the previous bounty. I'm reviewing all the PRs currently before the end of the hackathon. My only comment from the video you posted (thanks for providing it!) is that the two-qubit gates, e.g., CNOT are not visualized what the second qubit register it acts on is.

I see no overlap in the code that was submitted between PRs for this bounty, and have provided feedback on each about how they solve the posted issue. In addition, all participants are allowed to submit multiple PRs.

@learningdungeon
Copy link
Copy Markdown

@learningdungeon @AbdullahKazi500 @ dhanaa abhirjk hey guys I would also suggesst checking yur work and pr if you made any contributions for the issue thnks again .

please check main.py at https://github.com/learningdungeon/GATE

@CodeMaverick2
Copy link
Copy Markdown
Author

CodeMaverick2 commented Feb 26, 2026

@benjimaclellan Thanks for the feedback! Updated the CNOT visualization both the control and target qubits are now shown on the circuit grid. Control qubit displays ●→{target} and target qubit displays ⊕←{control}, at the same time step. Clearing either end removes both.

Regarding the copying claims I had shared my implementation approach with you before anyone else commented on the issue, and this PR complements my earlier analog builder (#5). I appreciate you confirming there's no overlap. Happy to leave it at that and let the work speak for itself.

Demo -

Screen.Recording.2026-02-27.023909.mp4

@CodeMaverick2
Copy link
Copy Markdown
Author

CodeMaverick2 commented Feb 26, 2026

@benjimaclellan Also fixed gate colors on the circuit grid each gate type now renders in its distinct color: - X = red
Z = blue
H = purple
CNOT = orange
I = grey

Screenshot 2026-02-27 025458

Copy link
Copy Markdown
Member

@benjimaclellan benjimaclellan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @CodeMaverick2, thanks for making those changes. The PR tackles the bounty nicely and looks like a useful addition to the demo - I'll accept it now and assign the bounty to this submission.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants